package ar.com.maddes.creenciasadventistas.ui;


import android.os.AsyncTask;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import ar.com.maddes.creenciasadventistas.StripActivity;
import ar.com.maddes.creenciasadventistas.database.Creencia;

public class PageChangeListener implements OnPageChangeListener {

	StripActivity mContext;
	
	public PageChangeListener(StripActivity context) {
		mContext = context;
	}

	@Override
	public void onPageSelected(int position) {
		new LoadTitle().execute((long) position+1);
	}


	private class LoadTitle extends AsyncTask<Long, Object, String> {
		@Override
		protected String doInBackground(Long... params) {
			return Creencia.getDoctrina(params[0]);
		}

		@Override
		protected void onPostExecute(String title) {
			super.onPostExecute(title);
			mContext.setTitle(title);
		}
	}


	@Override
	public void onPageScrollStateChanged(int arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onPageScrolled(int arg0, float arg1, int arg2) {
		// TODO Auto-generated method stub
		
	}
}
